home *** CD-ROM | disk | FTP | other *** search
/ Visual Cafe 3 / Visual Cafe 3.ISO / Vcafe / JFC.bin / MetalInternalFrameBorder.java < prev    next >
Text File  |  1998-06-30  |  4KB  |  106 lines

  1. /*
  2.  * @(#)MetalInternalFrameBorder.java    1.4 98/02/02
  3.  * 
  4.  * Copyright (c) 1997 Sun Microsystems, Inc. All Rights Reserved.
  5.  * 
  6.  * This software is the confidential and proprietary information of Sun
  7.  * Microsystems, Inc. ("Confidential Information").  You shall not
  8.  * disclose such Confidential Information and shall use it only in
  9.  * accordance with the terms of the license agreement you entered into
  10.  * with Sun.
  11.  * 
  12.  * SUN MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF THE
  13.  * SOFTWARE, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
  14.  * IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
  15.  * PURPOSE, OR NON-INFRINGEMENT. SUN SHALL NOT BE LIABLE FOR ANY DAMAGES
  16.  * SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING
  17.  * THIS SOFTWARE OR ITS DERIVATIVES.
  18.  * 
  19.  */
  20.  
  21. package com.sun.java.swing.plaf.metal;
  22.  
  23. import com.sun.java.swing.*;
  24. import com.sun.java.swing.border.*;
  25. import com.sun.java.swing.plaf.basic.*;
  26. import java.awt.*;
  27. import java.awt.event.*;
  28. import com.sun.java.swing.plaf.*;
  29.  
  30. /**
  31.  * The Flush 3D border used for Metal buttons, text fields, etc.
  32.  * <p>
  33.  * Warning: serialized objects of this class will not be compatible with
  34.  * future swing releases.  The current serialization support is appropriate
  35.  * for short term storage or RMI between Swing1.0 applications.  It will
  36.  * not be possible to load serialized Swing1.0 objects with future releases
  37.  * of Swing.  The JDK1.2 release of Swing will be the compatibility
  38.  * baseline for the serialized form of Swing objects.
  39.  *
  40.  * @version 1.4 02/02/98
  41.  * @author Steve Wilson
  42.  */
  43. public class MetalInternalFrameBorder extends AbstractBorder {
  44.  
  45.   private static final Insets insets = new Insets(6, 6, 6, 6);
  46.  
  47.   private static final int corner = 14;
  48.  
  49.   public void paintBorder(Component c, Graphics g, int x, int y, 
  50.               int w, int h) {
  51.  
  52.     Color background;
  53.     Color highlight;
  54.     Color shadow;
  55.  
  56.     if (c instanceof JInternalFrame && ((JInternalFrame)c).isSelected()) {
  57.         background = MetalLookAndFeel.getPrimaryControlDarkShadow();
  58.     highlight = MetalLookAndFeel.getPrimaryControlShadow();
  59.     shadow = MetalLookAndFeel.getPrimaryControlInfo();
  60.     } else {
  61.         background = MetalLookAndFeel.getControlDarkShadow();
  62.     highlight = MetalLookAndFeel.getControlShadow();
  63.     shadow = MetalLookAndFeel.getControlInfo();
  64.     }
  65.  
  66.       g.setColor(background);
  67.       // Draw outermost lines
  68.       g.drawLine( 1, 0, w-2, 0);
  69.       g.drawLine( 0, 1, 0, h-2);
  70.       g.drawLine( w-1, 1, w-1, h-2);
  71.       g.drawLine( 1, h-1, w-2, h-1);
  72.  
  73.       // Draw the bulk of the border
  74.       for (int i = 1; i < 6; i++) {
  75.       g.drawRect(x+i,y+i,w-(i*2)-1, h-(i*2)-1);
  76.       }
  77.  
  78.       g.setColor(highlight);
  79.       // Draw the Long highlight lines
  80.       g.drawLine( corner, 1, w-corner-1, 1);
  81.       g.drawLine( 1, corner, 1, h-corner-1);
  82.       g.drawLine( w-5, corner, w-5, h-corner-1);
  83.       g.drawLine( corner, h-5, w-corner-1, h-5);
  84.  
  85.       // Draw the short highlight lines
  86.       g.drawLine( corner, 2, corner, 4);
  87.       g.drawLine( 2, corner, 4, corner);
  88.       g.drawLine( w-4, corner, w-2, corner);
  89.       g.drawLine( corner, h-4, corner, h-2);
  90.  
  91.       // Draw the short shadow lines
  92.       g.setColor(shadow);
  93.       g.drawLine( w-corner-1, 2, w-corner-1, 4);
  94.       g.drawLine( 2, h-corner-1, 4, h-corner-1);
  95.       g.drawLine( w-4, h-corner-1, w-2, h-corner-1);
  96.       g.drawLine( w-corner-1, h-4, w-corner-1, h-2);
  97.  
  98.  
  99.   }
  100.   
  101.   public Insets getBorderInsets(Component c)       {
  102.     return insets;
  103.   }
  104. }
  105.  
  106.